/*
 * $LastChangedDate: 2007-06-21 14:06:23 +0200 (Thu, 21 Jun 2007) $
 * $LastChangedRevision: 201 $
 * $LastChangedBy: david $
 */


#ifndef _FILEMNGR_H_
#define _FILEMNGR_H_

#include <fstream>
#include "ServerSocket.h"
#include "Thread.h"
#include "Log.h"
#include "FileLock.h"

class Log;

class FileMngr : public Thread 
{
	friend class Log;
public:
	FileMngr(std::string path, FileLock* lock, ServerSocket& socket);
	virtual ~FileMngr();

protected:
	std::string read();
	void write(std::string s);
	std::string servePetition(std::string petition);
	void update_id(std::string mode);
	void open(std::string mode);
	virtual void run();

	std::string fpath;
	ServerSocket socket;
	std::string id;
	static int numFileMngr;
	FileLock* lock;
	fstream file;
};

#endif /* _FILEMNGR_H_ */
